<template>
  <div class="login rotateInt animated">
    <div class="wrapper">
      <div class="container">
        <div class="login-form">
          <h3>
            <span class="checked">帐号登录</span>
          </h3>
          <div class="input">
            <input type="text" placeholder="请输入帐号" v-model="username" />
          </div>
          <div class="input">
            <input type="password" placeholder="请输入密码" v-model="password" />
          </div>
          <div class="login-btn-box" @click="login">登 录</div>
          <div class="login-btn-box" @click="register">注 册</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import store from "./../store/store.js";
import { mapActions } from "vuex";
import { api } from "./api/index";
export default {
  name: "login",
  data() {
    return {
      username: "",
      password: "",
      userId: ""
    };
  },
  methods: {
    login() {
      console.log("login");
      let dic={
        username:this.username,
        password:this.password
      }
      api({
        // url:"/v1/fls/login",
        url:"/login",
        method:"POST",
        data:dic
      }).then(res => {
          console.log(res);
          console.log(res.data.code);
          if (res.data.code === 1000) {
            console.log("if条件成立");
            localStorage.setItem("token", JSON.stringify(res.data.token));
            localStorage.setItem("user", this.username);
            console.log(localStorage.getItem("token"));
            this.$router.push({
              name: "zcapi",
              query: {
                da: this.username
              }
            });
          } else {
            // Toast({ message: res.data.message, duration: 1500 }); // ui弹窗提示
            this.$message("用户名或密码错误，请重新输入！")

          }
        });
    },
    register() {
      this.$router.push("zczpi");
    },
    tes() {
      this.axios
        .post("/api/index/", {
          username,
          password
        })
        .then(res => {
          console.log(res.data);
        });
    }
  }
};
</script>
<style lang="scss">
.login {
  height: 100%;
  .wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    // background: url("./../imgs/login2.png") center no-repeat;
    background-size: cover;
    min-width: 1366px;
    min-height: 768px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    
    .container {
      height: 476px;
      .login-form {
        box-sizing: border-box;
        padding-left: 31px;
        padding-right: 31px;
        width: 410px;
        height: 400px;
        background-color: #fff;
        bottom: 250px;
        // right: 150px;
        // opacity: 0.45;
        border: 1px solid;
      }
    }
    h3 {
      line-height: 23px;
      font-size: 24px;
      text-align: center;
      margin: 40px auto 49px;
      .checked {
        color: #ff6600;
      }
      .sep-line {
        margin: 0 32px;
      }
    }
    .input {
      display: inline-block;
      width: 348px;
      height: 50px;
      border: 1px solid #e5e5e5;
      margin-bottom: 20px;
      line-height: 35px;
      input {
        font-size: 16px;
        display: inline-block;
        box-sizing: border-box;
        width: 100%;
        height: 100%;
        border: none;
        padding: 10px;
        line-height: 50px;
        outline: none;
        margin-top: auto auto;
      }
    }
    .login-btn-box {
      color: #ffffff;
      display: inline-block;
      width: 100%;
      line-height: 50px;
      margin-top: 10px;
      font-size: 16px;
      background-color: #ff6600;
      text-align: center;
      font-size: 16px;
      font-weight: bold;
    }

    .tips {
      margin-top: 14px;
      display: flex;
      justify-content: space-between;
      font-size: 14px;
      cursor: pointer;
      .sms {
        color: #ff6600;
      }
      .reg {
        color: #999999;
        span {
          margin: 0 7px;
        }
      }
    }
  }
}
</style>
